package  
{
	import org.flixel.FlxGroup;
	import org.flixel.FlxPoint;
	import org.flixel.FlxState;
	import org.flixel.FlxTilemap;
	import org.flixel.FlxSprite;
	
	public class MainState extends FlxState
	{		
		[Embed(source = '../assets/images/p5050.png')] private static var testImage : Class;
				
		private var customers : Vector.<Customer>;
		
		private var bgGroup : FlxGroup;
		private var peopleGroup : FlxGroup;
		
		public function MainState() 
		{
			customers = new Vector.<Customer>();
			super();
		}
		
		override public function create():void 
		{
			super.create();
			
			bgGroup = new FlxGroup(10);
			peopleGroup = new FlxGroup(100);
						
			//TODO: Both points within map.
			var wp : Waypoint = new Waypoint(new FlxPoint(100, 100));
			var wp2 : Waypoint = new Waypoint(new FlxPoint(200, 150));
			var route : Route = new Route(wp, wp2);
			
			var customerTest : Customer = new Customer(Customer.CUSTOMER_BASIC, route);
			customerTest.loadGraphic(testImage, false, false, 50);
			customers.push(customerTest);
			peopleGroup.add(customerTest);
			
			add(bgGroup);
			add(peopleGroup);
		}
		
		override public function update():void 
		{
			for (var i : int = 0; i < customers.length; )
			{
				if (customers[i].state == Customer.STATE_DEAD)
				{
					peopleGroup.remove(customers[i], true);
					customers.splice(i, 1);
				}
				else
					i++;
			}
			super.update();
		}
	}
}